#pragma once

#include "Ogre.h"

#include "OgreBulletDynamicsRigidBody.h"				 // for OgreBullet
#include "Shapes/OgreBulletCollisionsStaticPlaneShape.h" // for static planes
#include "Shapes/OgreBulletCollisionsBoxShape.h"		 // for Boxes

using namespace Ogre;

class EntityManager 
{
protected:
	SceneManager *mSceneMgr;

	OgreBulletDynamics::DynamicsWorld *mWorld;
	OgreBulletCollisions::DebugDrawer *debugDrawer;

	std::deque<OgreBulletDynamics::RigidBody *>         mBodies;
 	std::deque<OgreBulletCollisions::CollisionShape *>  mShapes;

	int mNumEntitiesInstanced;

	EntityManager();
	~EntityManager();
public:
	typedef enum
	{
		SHAPE_BOX,
		SHAPE_SPHERE
	} EntityType;
	/**
	singleton access
	@return The single instance of this class
	*/
	static EntityManager &Instance()
	{
		static EntityManager instance;
		return instance;
	}

	bool Startup(SceneManager *sceneMgr, Vector3 &gravityVector, AxisAlignedBox &bounds);
	void Shutdown();

	bool AddEntity(Vector3 &Position, Vector3 &StartVel, EntityType type);

	void StepSimulation(Ogre::Real time)
	{
		mWorld->stepSimulation(time);
	}
};